﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.WinKStart
 * 
 * Description: Enum and Convert Class to work with ExecutionProcedures 
 * 
 * Created:     22.07.2012
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2012 by WMSSoft.de
 * 
 * Lizense:     GPLv3
 * 
 * History:     22.07.2012 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WMSSoft.Lib.Enums
{
    /// <summary>
    /// Enum to Describe the execution code procedure
    /// </summary>
    public enum eExecutionProcedure
    {
        /// <summary>
        /// a Unknown Procedure was given
        /// </summary>
        Unknown = 0,

        /// <summary>
        /// Execute the methode to lock the system
        /// </summary>
        lock_workstation = 1,

        /// <summary>
        /// Execute the methode to logout current user from windows
        /// </summary>
        system_logout,

        /// <summary>
        /// Execute methode to activate the standby mode
        /// </summary>
        energy_save_mode,

        /// <summary>
        /// Execute methode to activate the hibernation mode
        /// </summary>
        hibernate_mode,

        /// <summary>
        /// Execute the code to view the Program - settings dialog
        /// </summary>
        winkstart_settings,

        /// <summary>
        /// Execute the code to view informations about the program
        /// </summary>
        winkstart_about,

        /// <summary>
        /// Execute the code to close WinKStart
        /// </summary>
        winkstart_close
    }

    /// <summary>
    /// Contains methods to convert a eExecutionProcedure to a string or a string to eExecutionProcedure
    /// </summary>
    public static class cExecutionProcedure
    {
        /// <summary>
        /// Convert a string to an eExecutionProcedure
        /// </summary>
        /// <param name="Value">string with execution procedure</param>
        /// <returns>eExecutionProcedure, Unknown if procedure does not exist</returns>
        public static eExecutionProcedure GetEnumValueFromString(string Value)
        {
            try
            {
                if (Value.ToUpper() == "LOCK_WORKSTATION") return eExecutionProcedure.lock_workstation; //lock_workstation
                else if (Value.ToUpper() == "SYSTEM_LOGOUT") return eExecutionProcedure.system_logout; //system_logout
                else if (Value.ToUpper() == "ENERGY_SAVE_MODE") return eExecutionProcedure.energy_save_mode; //energy_save_mode
                else if (Value.ToUpper() == "HIBERNATE_MODE") return eExecutionProcedure.hibernate_mode; //hibernate_mode
                else if (Value.ToUpper() == "WINKSTART_SETTINGS") return eExecutionProcedure.winkstart_settings;
                else if (Value.ToUpper() == "WINKSTART_ABOUT") return eExecutionProcedure.winkstart_about;
                else if (Value.ToUpper() == "WINKSTART_CLOSE") return eExecutionProcedure.winkstart_close;
                else return eExecutionProcedure.Unknown;
            }
            catch
            {
                return eExecutionProcedure.Unknown;
            }
        }

        /// <summary>
        /// Convert a eExecutionProcedure to a string
        /// </summary>
        /// <param name="Value"></param>
        /// <returns></returns>
        public static string GetStringFromEnum(eExecutionProcedure Value)
        {
            try
            {
                switch (Value)
                {
                    case eExecutionProcedure.energy_save_mode: return "energy_save_mode";
                    case eExecutionProcedure.lock_workstation: return "lock_workstation";
                    case eExecutionProcedure.system_logout: return "system_logout";
                    case eExecutionProcedure.hibernate_mode: return "hibernate_mode";
                    default: return "Unknown";
                }
            }
            catch
            {
                return "Unknown";
            }
        }
    }
}
